#ifndef __ADCSAMPLE_H
#define __ADCSAMPLE_H

#include "tim.h"
#include "adc.h"

#define ADCSAMPLE_MAX_LEN					(8192)
#define ADC_REF_VOLTAGE						(3.3)
#define ADC_VALUE_TO_ANALOG(VAL)		((float)((VAL/4096.0)*ADC_REF_VOLTAGE))
#define ANALOG_TO_ADC_VALUE(VAL)		((uint16_t)((VAL/ADC_REF_VOLTAGE)*4095.0))

void adcsample_init();
uint16_t* adcsample_get_points();
int16_t adcsample_find_rasing(uint16_t *points, uint16_t trig_level, size_t N);
size_t find_max_idx(uint16_t *points, size_t length);
uint16_t find_max_value(uint16_t *points, size_t length);
uint16_t find_min_value(uint16_t *points, size_t length);

#endif